﻿using System;
using System.Web.Mvc;
using System.Web.Routing;
using Castle.Windsor;

namespace Genrsis.WorkitemTracking.Web.Infrastructure.IoC
{
    public class WindsorControllerFactory : DefaultControllerFactory
    {
        private readonly IWindsorContainer _container;

        public WindsorControllerFactory(IWindsorContainer container)
        {
            _container = container;
        }

        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {
            //if (controllerType == null) return base.GetControllerInstance(requestContext, controllerType);

            return (IController)_container.Resolve(controllerType);
        }

    }
}